package com.itboye.ihomebank.activity.myzhujia;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.base.BaseOtherActivity;
import com.itboye.ihomebank.bean.ResultEntity;
import com.itboye.ihomebank.bean.WoDeQiuZuBean;
import com.itboye.ihomebank.constants.SPContants;
import com.itboye.ihomebank.custom.XListView;
import com.itboye.ihomebank.presenter.HousePresenter;
import com.itboye.ihomebank.util.SPUtils;

import java.util.List;
import java.util.Observable;
import java.util.Observer;

public class ActivityMyappointment extends BaseOtherActivity implements
		Observer {
	View v_statusbar;
	TextView add_shap_title_tv, txt_isempty;
	ImageView close_icon;
	XListView _listView;
	HousePresenter housePresenter;
	String uid;
	LinearLayout nodata;

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub

	}

	@Override
	protected int layout_id() {
		// TODO Auto-generated method stub
		return R.layout.activity_travel;
	}

	@Override
	protected void onInitController() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void onInit() {
		// TODO Auto-generated method stub
		setStatusBarHeight(v_statusbar);
		add_shap_title_tv.setText("我的预约");
		showProgressDialog("数据加载中,请稍后", true);
		txt_isempty.setText("数据加载中");
		uid = SPUtils.get(this, null, SPContants.USER_ID, "") + "";
		close_icon.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
		_listView.setPullLoadEnable(false);
		_listView.setPullRefreshEnable(false);
		housePresenter = new HousePresenter(this);
		housePresenter.getQiuZu(uid);

	}

	@Override
	protected void onReadIntent(Bundle bundle) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(Observable observable, Object data) {
		// TODO Auto-generated method stub
		ResultEntity entity = handlerError(data);
		if (entity != null) {
			List<WoDeQiuZuBean> bean = (List<WoDeQiuZuBean>) entity.getData();
			if (bean == null) {
				_listView.setVisibility(View.GONE);
				nodata.setVisibility(View.VISIBLE);
				txt_isempty.setText("暂时没有数据哦...");
			} else if (bean.size() <= 0) {
				_listView.setVisibility(View.GONE);
				nodata.setVisibility(View.VISIBLE);
				txt_isempty.setText("暂时没有数据哦...");
			} else {
				nodata.setVisibility(View.GONE);
				_listView.setVisibility(View.VISIBLE);
//				_listView.setAdapter(new WodeYuYueAdapter(this, bean,
//						R.layout.item_wodeyuyue));
			}
		}
		try {
			closeProgressDialog();
		} catch (Exception e) {
			// TODO: handle exception
		}

	}
}
